﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Text;
using System.IO;

public partial class UserControl_nearShop : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Repeater1.DataSource = NearShops;
        //Repeater1.DataBind();

        //StringBuilder sBuilder = new StringBuilder();
        //foreach (var shop in NearShops)
        //{
        //    sBuilder.AppendLine("<div>");
        //    sBuilder.AppendFormat("<div class=\"nearshop-name\">{0} </div>", shop.NearShopName);
        //    sBuilder.AppendFormat("<div class=\"nearshop-share\">分享数：{0} </div>", shop.NearShopShareNum);

        //    UserControl_StaticRate rateControl = this.LoadControl("StaticRate.ascx") as UserControl_StaticRate;
        //    rateControl.Rate = (int)shop.NearShopDebateScore;
        //    rateControl.IsLarge = false;

        //    sBuilder.Append(RenderUserControl(rateControl));

        //    sBuilder.AppendFormat("<div class=\"nearshop-score\">{0} </div>", shop.NearShopDebateScore);
        //    sBuilder.AppendFormat("<a href=\"#\">评论数{0}</a>", shop.NearShopDedateNum);

        //    sBuilder.AppendLine("</div>");
        //}

        //txtGeneratedHtmlContainer.InnerHtml = sBuilder.ToString();
    }

    protected string RenderUserControl(UserControl control)
    {
        StringBuilder sb = new StringBuilder();
        HtmlTextWriter htmlWriter = new HtmlTextWriter(new StringWriter(sb));
        control.RenderControl(htmlWriter);
        htmlWriter.Flush();
        return sb.ToString();
    }
    public List<NearShop> NearShops
    {
        get
        {
            if (ViewState["NearShops"] == null)
            {
                return null;
            }
            return (List<NearShop>)ViewState["NearShops"];
        }
        set { ViewState["NearShops"] = value; }
    }
}

[Serializable]
public class NearShop
{
    private string _nearShopName;
    private int _nearShopShareNum;
    private int _nearShopDebateScore;
    private int _nearShopDebateNum;
    public string NearShopName
    {
        get { return _nearShopName; }
        set { _nearShopName = value; }
    }
    public int NearShopShareNum
    {
        get { return _nearShopShareNum; }
        set { _nearShopShareNum = value; }
    }
    public int NearShopDebateScore
    {
        get { return _nearShopDebateScore; }
        set { _nearShopDebateScore = value; }
    }
    public int NearShopDedateNum
    {
        get { return _nearShopDebateNum; }
        set { _nearShopDebateNum = value; }
    }
}